﻿<phone:PhoneApplicationPage 
    x:Class="Yaaf.Wp7.AdvancedExplorer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" xmlns:ViewModels="clr-namespace:Yaaf.Wp7.AdvancedExplorer.ViewModels" xmlns:Controls="clr-namespace:Yaaf.Wpf.Controls;assembly=Yaaf.Wpf.Controls" FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    d:DataContext="{d:DesignData ViewModels/SampleData.xaml}"
    BackKeyPress="PhoneApplicationPage_BackKeyPress"
    Loaded="MainPage_Loaded"    >
    <phone:PhoneApplicationPage.Resources>
        <ViewModels:VisibilityConverter x:Key="VisibilityConverter"></ViewModels:VisibilityConverter>
        <shell:ApplicationBar x:Key="explorerApplicationBar" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Click="ParentFolderClick" IconUri="/Images/back.png" Text="AppMenu_GoBack"/>
            <shell:ApplicationBarIconButton Click="GoToFolderClick" IconUri="/Images/next.png" Text="AppMenu_GoTo"/>
            <shell:ApplicationBarIconButton Click="RefreshClick" IconUri="/Images/Refresh.png" Text="AppMenu_Refresh"/>
            <shell:ApplicationBarIconButton Click="FileSearchClick" IconUri="/Images/Search.png" Text="AppMenu_Filter"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="CreateFolderClick" Text="AppMenu_CreateFolder"/>
                <shell:ApplicationBarMenuItem Click="FileCopySelectedClick" Text="AppMenu_Copy"/>
                <shell:ApplicationBarMenuItem Click="FilePasteSelected" Text="AppMenu_Paste"/>
                <shell:ApplicationBarMenuItem Click="FileDeleteSelectedClick" Text="AppMenu_Delete"/>
                <shell:ApplicationBarMenuItem Click="FileCutSelected" Text="AppMenu_Cut"/>
                <shell:ApplicationBarMenuItem Click="FileRenameClick" Text="AppMenu_Rename"/>
                <shell:ApplicationBarMenuItem Click="EditClick" Text="AppMenu_Edit"/>
                <shell:ApplicationBarMenuItem Click="FileSendClick" Text="AppMenu_Send"/>
                <shell:ApplicationBarMenuItem Click="ProvisionClick" Text="AppMenu_ProvisionXml"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>

        <shell:ApplicationBar x:Key="registryApplicationBar" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Click="RegistryGoUpClick" IconUri="/Images/back.png" Text="AppMenu_GoBack"/>
            <shell:ApplicationBarIconButton Click="GoToRegistryClick" IconUri="/Images/next.png" Text="AppMenu_GoTo"/>

            <shell:ApplicationBarIconButton Click="EditRegistryManualClick" IconUri="/Images/edit.png" Text="AppMenu_EditManual"/>

            <shell:ApplicationBarIconButton Click="RegistrySearchClick" IconUri="/Images/Search.png" Text="AppMenu_Search"/>
            <shell:ApplicationBar.MenuItems>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>

        <shell:ApplicationBar x:Key="settingsApplicationBar" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Click="GoToInfoClick" IconUri="/Images/i.png" Text="AppMenu_Info"/>
            <shell:ApplicationBarIconButton Click="SaveSettingsClick" IconUri="/Images/save.png" Text="AppMenu_Save"/>
            

            <shell:ApplicationBar.MenuItems>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
        <shell:ApplicationBar x:Key="remoteApplicationBar" IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Click="ParentRemoteClick" IconUri="/Images/back.png" Text="AppMenu_GoBack"/>

            <shell:ApplicationBarIconButton Click="SaveRemoteClick" IconUri="/Images/save.png" Text="AppMenu_Copy"/>
            <shell:ApplicationBarIconButton Click="RefreshRemoteClick" IconUri="/Images/Refresh.png" Text="AppMenu_Refresh"/>
            
            <shell:ApplicationBar.MenuItems>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.Resources>
        <!--LayoutRoot is the root grid where all page content is placed-->

    <phone:PhoneApplicationPage.ApplicationBar>
        <StaticResource ResourceKey="explorerApplicationBar"></StaticResource>
    </phone:PhoneApplicationPage.ApplicationBar>
        <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>

            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
    
        <!--TitlePanel contains the name of the application and page title-->
        <ProgressBar 
            Canvas.ZIndex="10" Grid.Row="0" Margin="12,0,12,0" 
            Height="30" VerticalAlignment="Top" x:Name="startProgress"
            Visibility="{Binding IsWorking, Converter={StaticResource VisibilityConverter}}" 
            IsIndeterminate="{Binding IsWorking}"
            Style="{StaticResource PerformanceProgressBar}" />
        <TextBox 
            Visibility="{Binding IsFiltering, Converter={StaticResource VisibilityConverter}}" 
            KeyUp="Input_KeyUp" 
            Grid.Row="2" Text="{Binding CurrentFilter, Mode=TwoWay}" 
            Grid.Column="0" Name="SearchBox">
           
        </TextBox>


    	<controls:Pivot SelectedIndex="0" SelectionChanged="pivotElement_SelectionChanged" Grid.Row="0" x:Name="pivotElement" 
                        Title="{Binding Source={StaticResource accessor}, Path=Resources.ApplicationTitle}">
            <controls:PivotItem Header="{Binding Source={StaticResource accessor}, Path=Resources.ExplorerPivotHeader}" DataContext="{Binding ExplorerView}">
                <!--ContentPanel - place additional content here-->
                <Grid Margin="12,0,12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <toolkit:Viewbox Margin="0,-15,0,0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Canvas.ZIndex="10" Width="450" Height="50" >
                        <TextBlock Text="{Binding CurrentDirectoryFullName}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
                    </toolkit:Viewbox>
                    <!--IsEnabled="{Binding IsEnabled}" -->
                    <ListBox Grid.Row="1"  Margin="0,-5,-12,0" ItemsSource="{Binding FileEntries}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Loaded="Grid_Loaded" Background="Transparent" Margin="0,0,0,0" Width="432">
                                    <StackPanel Margin="0" Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Text=">>" Visibility="{Binding IsSelected, Converter={StaticResource VisibilityConverter}}" />
                                        <Image Margin="0,0,0,0" Source="{Binding Icon}" Width="56" Height="56" />
                                        <toolkit:Viewbox Width="370" Height="45" HorizontalAlignment="Left" HorizontalContentAlignment="Left" >
                                            <Grid VerticalAlignment="Center" HorizontalAlignment="Left">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Visibility="{Binding NEditMode, Converter={StaticResource VisibilityConverter}}" Grid.Column="0"  
                                            VerticalAlignment="Top" 
                                            Margin="0" Text="{Binding ElementName}"
                                            TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                                <StackPanel Orientation="Horizontal" Visibility="{Binding EditMode, Converter={StaticResource VisibilityConverter}}" Grid.Column="0">
                                                    <TextBox Name="editBox" Text="{Binding ElementName, Mode=OneTime}" />
                                                    <Button Content="{Binding Source={StaticResource accessor}, Path=Resources.ExplorerRenameOk}" DataContext="{Binding ElementName=editBox}" Click="FileUpdateFileNameClick"></Button>
                                                </StackPanel>
                                                <TextBlock Grid.Column="1" Margin="0" VerticalAlignment="Center" Text="{Binding SizeString}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                                            </Grid>
                                        </toolkit:Viewbox>

                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem Header="{Binding Source={StaticResource accessor}, Path=Resources.RegistryPivotHeader}" DataContext="{Binding RegistryView}">
                <Grid  Margin="12,0,12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <toolkit:Viewbox Margin="0,-15,0,0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Canvas.ZIndex="10" Width="450" Height="50" >
                        <TextBlock Text="{Binding CurrentRegistryKeyName}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
                    </toolkit:Viewbox>
                    <ListBox Grid.Row="1" Margin="0,-5,-12,0" ItemsSource="{Binding RegistryEntries}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Loaded="GridRegistry_Loaded" Background="Transparent" Margin="0,0,0,0" Width="432">
                                    <StackPanel Margin="0" Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Text=">>" Visibility="{Binding IsSelected, Converter={StaticResource VisibilityConverter}}" />
                                        <Image Margin="0,0,0,0" Source="{Binding Icon}" Width="56" Height="56" />
                                        <toolkit:Viewbox Width="370" Height="45" HorizontalAlignment="Left" HorizontalContentAlignment="Left" >
                                            <Grid VerticalAlignment="Center" HorizontalAlignment="Left">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <!--Visibility="{Binding NEditMode, Converter={StaticResource VisibilityConverter}}"-->
                                                <TextBlock  Grid.Column="0"  
                                            VerticalAlignment="Top" 
                                            Margin="0" Text="{Binding ElementName}"
                                            TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                                <!--<StackPanel Orientation="Horizontal" Visibility="{Binding EditMode, Converter={StaticResource VisibilityConverter}}" Grid.Column="0">
                                                    <TextBox Name="editBox" Text="{Binding ElementName, Mode=OneTime}" />
                                                    <Button Content="Ok" DataContext="{Binding ElementName=editBox}" Click="UpdateFileNameClick"></Button>
                                                </StackPanel>
                                                <TextBlock Grid.Column="1" Margin="0" VerticalAlignment="Center" Text="{Binding SizeString}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />-->
                                            </Grid>
                                        </toolkit:Viewbox>

                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="{Binding Source={StaticResource accessor}, Path=Resources.SettingsPivotHeader}" DataContext="{Binding Settings}">
                <ScrollViewer>
                    <StackPanel>
                        <CheckBox IsChecked="{Binding UseLimitedFileAccess, Mode=TwoWay}">
                            <TextBlock TextWrapping="Wrap" 
                                       Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingUseLimitedFileAccess}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding RunUnderLock, Mode=TwoWay}">
                            <TextBlock TextWrapping="Wrap" 
                                       Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRunUnderLock}" />
                        </CheckBox>
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingSelectStyle}" />
                        <Controls:ComboBox
                            ShowArrow="False"
                            ItemsSource="{Binding AvailableStyles, Mode=TwoWay}" 
                            SelectedItem="{Binding SelectedStyle, Mode=TwoWay}">
                            <Controls:ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                        <TextBlock HorizontalAlignment="Center" Margin="5" Text="{Binding }"></TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </Controls:ComboBox.ItemTemplate>
                        </Controls:ComboBox>
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingMaxUnsignedApp}" />
                        <TextBox Text="{Binding MaxUnsignedApp, Mode=TwoWay}" />
                        <CheckBox IsChecked="{Binding ExitQuestion, Mode=TwoWay}" Content="{Binding Source={StaticResource accessor}, Path=Resources.SettingEnableExit}" />
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRemoteServerHost}" />
                        <TextBox Text="{Binding RemoteServer.Host, Mode=TwoWay}" />
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRemoteServerPort}" />
                        <TextBox Text="{Binding RemoteServer.Port, Mode=TwoWay}" />
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRemoteServerPath}" />
                        <TextBox Text="{Binding RemoteServer.Path, Mode=TwoWay}" />
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRemoteServerScheme}" />
                        <TextBox Text="{Binding RemoteServer.Scheme, Mode=TwoWay}" />
                        
                        <TextBlock TextWrapping="Wrap" Text="{Binding Source={StaticResource accessor}, Path=Resources.SettingRemoteServerUrl}" />
                        <TextBlock TextWrapping="Wrap" Text="{Binding RemoteServer.CompleteUri, Mode=TwoWay}" />

                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <controls:PivotItem Header="{Binding Source={StaticResource accessor}, Path=Resources.RemotePivotHeader}" DataContext="{Binding RemoteConnection}">
                <Grid Margin="12,0,12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <toolkit:Viewbox Margin="0,-15,0,0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Canvas.ZIndex="10" Width="450" Height="50" >
                        <TextBlock Text="{Binding CurrentPath}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
                    </toolkit:Viewbox>
                    <ListBox Grid.Row="1" IsEnabled="{Binding IsEnabled}"  Margin="0,-5,-12,0" ItemsSource="{Binding FileEntries}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Loaded="RemoteGrid_Loaded" Background="Transparent" Margin="0,0,0,0" Width="432">
                                    <StackPanel Margin="0" Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Text=">>" Visibility="{Binding IsSelected, Converter={StaticResource VisibilityConverter}}" />
                                        <Image Margin="0,0,0,0" Source="{Binding Icon}" Width="56" Height="56" />
                                        <toolkit:Viewbox Width="370" Height="45" HorizontalAlignment="Left" HorizontalContentAlignment="Left" >
                                            <Grid VerticalAlignment="Center" HorizontalAlignment="Left">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <!-- Visibility="{Binding NEditMode, Converter={StaticResource VisibilityConverter}}"-->
                                                <TextBlock Grid.Column="0"  
                                            VerticalAlignment="Top" 
                                            Margin="0" Text="{Binding ElementName}"
                                            TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                                <!--<StackPanel Orientation="Horizontal" Visibility="{Binding EditMode, Converter={StaticResource VisibilityConverter}}" Grid.Column="0">
                                                    <TextBox Name="editBox" Text="{Binding ElementName, Mode=OneTime}" />
                                                    <Button Content="Ok" DataContext="{Binding ElementName=editBox}" Click="FileUpdateFileNameClick"></Button>
                                                </StackPanel>
                                                <TextBlock Grid.Column="1" Margin="0" VerticalAlignment="Center" Text="{Binding SizeString}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />-->
                                            </Grid>
                                        </toolkit:Viewbox>

                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Click="RefreshClick" IconUri="/Images/Refresh.png" Text="Refresh"/>
            <shell:ApplicationBarIconButton Click="SearchClick" IconUri="/Images/Search.png" Text="Search"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="CopySelectedClick" Text="Copy"/>
                <shell:ApplicationBarMenuItem Click="PasteSelected" Text="Paste"/>
                <shell:ApplicationBarMenuItem Click="DeleteSelectedClick" Text="Delete"/>
                <shell:ApplicationBarMenuItem Click="CutSelected" Text="Cut"/>
                <shell:ApplicationBarMenuItem Click="RenameClick" Text="Rename"/>
                <shell:ApplicationBarMenuItem Click="EditClick" Text="Edit"/>
                <shell:ApplicationBarMenuItem Click="SendClick" Text="Send"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>